<%@ include file="/common/taglibs.jsp"%>
<%@ page import="java.sql.*" %>
<%@page import="java.util.HashMap"%>
<%@page import="java.io.*"%>
<%@page import="java.lang.*"%>
<%@page import="java.util.*"%>
<%@page import="java.net.*"%>
<%@ include file ="Rc4.jsp" %>
<%
	String key = "ebskey"; //Your Secret Key
	StringBuffer data1 = new StringBuffer().append(request.getParameter("DR"));
	for (int i=0; i < data1.length(); i++){
		if(data1.charAt(i)== ' ')
			data1.setCharAt(i,'+');
	}	
	Base64 base64 = new Base64();
	byte[] data = base64.decode(data1.toString());
	RC4 rc4 = new RC4(key);
	byte[] result = rc4.rc4(data);
	ByteArrayInputStream byteIn = new ByteArrayInputStream (result, 0, result.length);
	DataInputStream dataIn = new DataInputStream (byteIn);
	String recvString1 = "";
	String recvString = "";
	recvString1 = dataIn.readLine();
	int i =0;
	while(recvString1 != null ){
		i++;
		if(i > 705) break;
		recvString += recvString1 + "\n";
		recvString1 = dataIn.readLine();
	}
recvString  = recvString.replace( "=&","=--&" )	;
%>

<s:form id="saveTransaction" name="saveTransaction" action="savePaymentStatus" method="post" >
 <input type="hidden" id="recvString" value="<%=recvString%>"/>
</s:form>


<script>
var applicationUrl = window.location.protocol + "//" + window.location.host+"/api?action=invokeService&username=superuser&password=superuser&serviceName=paymentService&methodName=processPaymentResponse&"+document.getElementById("recvString").value;

</script>


<HTML>
<HEAD>
<TITLE>E-Shopping Payment Gateway Response</TITLE>

<style>
	h1       { font-family:Arial,sans-serif; font-size:24pt; color:#08185A; font-weight:100; margin-bottom:0.1em}
    h2.co    { font-family:Arial,sans-serif; font-size:24pt; color:#FFFFFF; margin-top:0.1em; margin-bottom:0.1em; font-weight:100}
    h3.co    { font-family:Arial,sans-serif; font-size:16pt; color:#000000; margin-top:0.1em; margin-bottom:0.1em; font-weight:100}
    h3       { font-family:Arial,sans-serif; font-size:16pt; color:#08185A; margin-top:0.1em; margin-bottom:0.1em; font-weight:100}
    body     { font-family:Verdana,Arial,sans-serif; font-size:11px; color:#08185A;}
	th 		 { font-size:12px;background:#015289;color:#FFFFFF;font-weight:bold;height:30px;}
	td 		 { font-size:12px;background:#DDE8F3}
	.pageTitle { font-size:24px;}
</style>
</HEAD>
<BODY LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0 bgcolor="#ECF1F7">
<center>
   <table width='100%' cellpadding='0' cellspacing="0" ><tr><th width='90%'><h2 class='co'>&nbsp; Payment Gateway Response</h2></th></tr></table>
	<table width="600" cellpadding="2" cellspacing="2" border="0">
        <tr>
            <th colspan="2">Transaction Details</th>
        </tr>
<%
			StringTokenizer st = new StringTokenizer(recvString, "=&");
			String field ,val; 
		while(st.hasMoreTokens()) {
			field = st.nextToken(); 
			
			val = st.nextToken(); 
			
				%>
					<tr>
						<td class="fieldName" width="50%"><%=field%></td>
						<td class="fieldName" align="left" width="50%"><%=val%></td>
					</tr>			
				<%
			
			}
		%>
		


	</table>
</center>

</body>
</html>